gtk#767 add a way to change the application_id of a toplevel wayland GdkSurface
authorCaolán McNamara <caolanm@redhat.com>
Tue, 7 Jul 2020 14:45:30 +0000 (15:45 +0100)
committerCaolán McNamara <caolanm@redhat.com>
Tue, 7 Jul 2020 14:56:12 +0000 (15:56 +0100)
so LibreOffice can reuse toplevels and get the right task icons

references;
 https://gitlab.gnome.org/GNOME/gtk/-/issues/767
 https://lists.freedesktop.org/archives/wayland-devel/2019-July/040704.html
 https://gitlab.freedesktop.org/wayland/wayland-protocols/commit/e0d6ad1d5e7e80321285a9b14ca3329289eb02e6
 https://bugs.documentfoundation.org/show_bug.cgi?id=125934
 https://bugzilla.redhat.com/show_bug.cgi?id=1334915
 https://bugreports.qt.io/browse/QTBUG-77182

gdk/wayland/gdksurface-wayland.c
gdk/wayland/gdkwaylandsurface.h

index 8f8b791f88dcf1e94e4de9b594fd30f0e5d5c073..ef3f277664ee363ca38fbe4e516104adbade955b 100644 (file)
@@ -1648,6 +1648,38 @@ create_zxdg_toplevel_v6_resources (GdkSurface *surface)
                                  surface);
 }
 
+void
+gdk_wayland_surface_set_application_id (GdkSurface *surface, const char* application_id)
+{
+  GdkWaylandSurface *impl;
+  GdkWaylandDisplay *display_wayland;
+
+  g_return_if_fail (application_id != NULL);
+
+  if (GDK_SURFACE_DESTROYED (surface))
+    return;
+
+  if (!is_realized_toplevel (surface))
+    return;
+
+  display_wayland = GDK_WAYLAND_DISPLAY (gdk_surface_get_display (surface));
+  impl = GDK_WAYLAND_SURFACE (surface);
+
+  switch (display_wayland->shell_variant)
+    {
+    case GDK_WAYLAND_SHELL_VARIANT_XDG_SHELL:
+      xdg_toplevel_set_app_id (impl->display_server.xdg_toplevel,
+                               application_id);
+      break;
+    case GDK_WAYLAND_SHELL_VARIANT_ZXDG_SHELL_V6:
+      zxdg_toplevel_v6_set_app_id (impl->display_server.zxdg_toplevel_v6,
+                                   application_id);
+      break;
+    default:
+      g_assert_not_reached ();
+    }
+}
+
 static void
 gdk_wayland_surface_create_xdg_toplevel (GdkSurface *surface)
 {
@@ -1702,19 +1734,7 @@ gdk_wayland_surface_create_xdg_toplevel (GdkSurface *surface)
   if (app_id == NULL)
     app_id = "GTK+ Application";
 
-  switch (display_wayland->shell_variant)
-    {
-    case GDK_WAYLAND_SHELL_VARIANT_XDG_SHELL:
-      xdg_toplevel_set_app_id (impl->display_server.xdg_toplevel,
-                               app_id);
-      break;
-    case GDK_WAYLAND_SHELL_VARIANT_ZXDG_SHELL_V6:
-      zxdg_toplevel_v6_set_app_id (impl->display_server.zxdg_toplevel_v6,
-                                   app_id);
-      break;
-    default:
-      g_assert_not_reached ();
-    }
+  gdk_wayland_surface_set_application_id (surface, app_id);
 
   maybe_set_gtk_surface_dbus_properties (surface);
   maybe_set_gtk_surface_modal (surface);
index 57decfcf3d078590cb0f433118b285e2ef16982d..4af358c33e47d6c1f0d0a4d513b750a3b70c0535 100644 (file)
@@ -74,6 +74,10 @@ GDK_AVAILABLE_IN_ALL
 gboolean                 gdk_wayland_surface_set_transient_for_exported (GdkSurface *surface,
                                                                          char      *parent_handle_str);
 
+GDK_AVAILABLE_IN_ALL
+void                     gdk_wayland_surface_set_application_id (GdkSurface *surface,
+                                                                 const char *application_id);
+
 void gdk_wayland_surface_announce_csd                        (GdkSurface *surface);
 
 G_END_DECLS